<template>
  <div>
    <label class="form-item">
      <span class="name">{{ fieldName }}</span>
      <input :type="type || 'text'"
             :placeholder="placeholder"
             :value="value"
             @input="onValueChanged($event.target.value)"
             class="value">
    </label>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
import {Component, Prop} from 'vue-property-decorator';

@Component
export default class FromItem extends Vue {
  @Prop({default: ''}) readonly value!: string;
  @Prop({required: true}) fieldName!: string;
  @Prop({required: true}) placeholder?: string;
  @Prop() type?: string;

  onValueChanged(value: string) {
    this.$emit('update:value', value);
  }
}
</script>

<style lang="scss" scoped>
.form-item {
  //background-color: #f5f5f5;
  font-size: 14px;
  padding-left: 16px;
  padding-right: 10px;
  display: flex;
  align-items: center;

  > .name {
    padding-right: 16px;
  }

  input {
    height: 44px;
    flex-grow: 1;
    background-color: transparent;
    border: none;
  }
}
</style>
